package net.sea.setup.ui.wizard.impl;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.List;
import java.util.Map;

import javax.swing.JLabel;

import com.jgoodies.forms.factories.FormFactory;
import net.sea.commons.constants.AppConstants;
import net.sea.commons.util.FileUtils;
import net.sea.setup.config.custom.CustomConfig;
import net.sea.setup.ui.wizard.AbstractWizardPage;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.RowSpec;

/**
 * 简介页面
 * 
 * @author 华成伍
 *
 */
@SuppressWarnings("serial")
public class IntroductionPage extends AbstractWizardPage {

	/**
	 * 創建panel
	 */
	@SuppressWarnings("unchecked")
	public IntroductionPage() {
		setBorder("\u7B80\u4ECB");
		setLayout(new FormLayout(new ColumnSpec[] {
				FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
				ColumnSpec.decode("10px"), ColumnSpec.decode("430px"), },
				new RowSpec[] { FormFactory.PARAGRAPH_GAP_ROWSPEC,
						RowSpec.decode("278px"), }));

		// 获取文件数据
		Map<String, String> dataMap = (Map<String, String>) contextInst
				.getAttribute(AppConstants.DATA_FILE);
		String dataFile = "";
		if (dataMap != null) {
			dataFile = dataMap.get(this.getClass().getName());
		}
		String introduction = "";
		try {
			introduction = FileUtils.read(new FileInputStream(new File(System
					.getProperty("current_dir"), dataFile)));
		} catch (FileNotFoundException e) {
			
		}
		JLabel introductionLb = new JLabel(introduction);
		add(introductionLb, "3, 2, center, center");

	}

	@Override
	public PageResult validateInput() {
		return new PageResult(true);
	}

	@Override
	protected List<CustomConfig> createCustomConfig() {
		return null;
	}

}
